#include <stdio.h>
#include "sqlist.h"


void test();
void test_merge();
void test_purge();

int main( int argc, char * argv[] ){

   // test();
    test_merge();
  //  test_purge();
    return 0;
}
void test_purge(){


    sqlink L = list_create();
    if( L == NULL )
    {
	return;
    }

    list_insert( L, 1 );
    list_insert( L, 2 );
    list_insert( L, 3 );
    list_insert( L, 19 );
    list_insert( L, 6 );
    list_insert( L, 2 );
    list_insert( L, 3 );
    list_insert( L, 3 );
    list_insert( L, 4 );
    list_insert( L, 8 );
    list_insert( L, 5 );
    list_insert( L, 8 );
    list_insert( L, 89 );
    list_insert( L, 8 );
    list_insert( L, 3 );
    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    list_purge( L );
    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );


}

void test_merge(){

    sqlink L = list_create();
    sqlink L2 = list_create();
    if( L == NULL || L2 == NULL )
    {
	return;
    }

    list_insert( L, 1 );
    list_insert( L, 2 );
    list_insert( L, 3 );
    list_insert( L, 4 );

    list_insert( L2, 4 );
    list_insert( L2, 5 );
    list_insert( L2, 6 );
    list_insert( L2, 7 );

    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    list_show( L2 );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L2 ) );
    printf("******************\n");
    list_merge( L, L2 );
    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    list_show( L2 );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L2 ) );

}

void test(){

    sqlink L;
    L = list_create();
    if( L == NULL )
    {
	return;
    }


    list_insert( L, 22 );
    list_insert( L, 36 );
    list_insert( L, 12 );
    list_insert( L, 56 );
    list_insert( L, 55 );
    list_insert( L, 3  );
    list_insert( L, 9  );

    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    printf( "表是否有值>>>>>>>>>>>>>>>>>>%d\n", list_empty( L ) );
    printf( "56在表的位置>>>>>>>>>>>>>>>>%d\n", list_locate( L, 56 ) );
    printf( "在表的第三个位置插入元素97>>%d\n", list_insert_pos( L, 97, 3 ) );
    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    printf( "删除表的第四个位置的元素>>>>%d\n", list_delete( L, 4 ));
    list_show( L );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    printf( "置空表>>>>>>>>>>>>>>>>>>>>>>%d\n", list_clear( L ) );
    printf( "表的长度>>>>>>>>>>>>>>>>>>>>%d\n", list_length( L ) );
    printf( "回收表>>>>>>>>>>>>>>>>>>>>>>%d\n", list_free( L ) );
}
